package sg.edu.nus.dashboard.advisor.control.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.rpc.IResponder;
	
	import sg.edu.nus.dashboard.advisor.control.business.GetAdviceDelegate;
	import sg.edu.nus.dashboard.advisor.control.event.GetAdviceEvent;
	import sg.edu.nus.dashboard.main.model.AppModelLocator;

	public class GetAdviceCommand implements ICommand, IResponder
	{
		private var model:AppModelLocator = AppModelLocator.getInstance();
		
		public function execute(event:CairngormEvent):void
		{
			var d:GetAdviceDelegate = new GetAdviceDelegate(this);
			var e:GetAdviceEvent = GetAdviceEvent(event);
			
			d.getAdviceByFlag(e.flag);
		}
		
		public function result(data:Object):void
		{
			model.advisor.adviceArr = data.result;
		}
		
		public function fault(info:Object):void
		{
		
		}
	}
}